package com.tengju.user.domain.model.user;

import lombok.AllArgsConstructor;

import java.util.Arrays;
import java.util.List;

@AllArgsConstructor
public enum DominationLevelEnum {

    GEN_SEC(65,"管辖级别，广义Sec", List.of(StarLevelEnum.EEC,StarLevelEnum.SEC)),
    EC(50,"管辖级别，ec", List.of(StarLevelEnum.EC)),
    GEN_CITY_STAR(25,"管辖级别，广义城市服务商", List.of(StarLevelEnum.CITY_STAR_ONE,StarLevelEnum.CITY_STAR_TWO,StarLevelEnum.CITY_STAR_THREE,StarLevelEnum.CITY_STAR_FOUR)),
    DEALER(0,"经销商", List.of(StarLevelEnum.NONE));

    Integer val;
    String desc;
    List<StarLevelEnum> starLevelEnums;

    public Integer getVal() {
        return val;
    }

    public String getDesc() {
        return desc;
    }

    public List<StarLevelEnum> getStarLevelEnums() {
        return starLevelEnums;
    }

    public static DominationLevelEnum parseByVal(Integer val) {
        if (val == null) {
            return null;
        }
        return Arrays.stream(DominationLevelEnum.values())
                .filter(k -> k.getVal().equals(val))
                .findFirst().orElse(null);
    }

    public static DominationLevelEnum parseByStarLevel(StarLevelEnum starLevel) {
        if (starLevel == null) {
            return null;
        }
        return Arrays.stream(DominationLevelEnum.values())
                .filter(k -> k.getStarLevelEnums().contains(starLevel))
                .findFirst().orElse(null);
    }


}
